 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page session="true" import="servlets.*" %>
<%@ page session="true" import="classes.*" %>
<%@ page session="true" import="beans.*" %>
<%@ page session="true" import="java.sql.ResultSet" %>
<%  	session = request.getSession(true); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@page import="java.util.List"%><html class="js" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sistema de Noticias</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<%@ include file="inc_head.jsp" %>  
<script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({ 
	// General options
	mode : "textareas", 
	theme : "advanced",
	plugins : "pagebreak,style,layer,advhr,advlink,emotions,contextmenu,paste,visualchars,nonbreaking,xhtmlxtras",

	// Theme options
	theme_advanced_buttons1 : "bold,italic,underline,|,fontselect,fontsizeselect",
	theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,blockquote,|,link,unlink,anchor,|,forecolor,backcolor",
	theme_advanced_buttons3 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom", 
	theme_advanced_resizing : true,

	// Example content CSS (should be your site CSS)
	content_css : "css/example.css",

	// Drop lists for link/image/media/template dialogs
	template_external_list_url : "js/template_list.js",
	external_link_list_url : "js/link_list.js",
	external_image_list_url : "js/image_list.js",
	media_external_list_url : "js/media_list.js",

	// Replace values for the template plugin
	template_replace_values : {
		username : "Some User",
		staffid : "991234"
	}
});
</script>

</head>
<body>  
<div id="page"> 
  <div id="wrapper"> 
    <div id="header"> <a href="?pg=index"><img src="index_arquivos/logo.png" alt="" id="logo"></a> 
      <h2><a href="Home"></a></h2> 
      <div class="slogan" style="color:#ffffff"></div> 
    </div> 
    <div id="left-col"> 
    
   <%@ include file="inc_menutop.jsp" %>   

      
      <!-- /nav -->  
      <div id="content"> 
        <div class="dbx-box" id="block-block"> 
          <div> 
            <% if (request.getParameter("msg_sucesso") != null) { %> 
            <div id="msg_sucesso"><% out.print(request.getParameter("msg_sucesso")); %></div>
            <% } %>
              <% if (request.getParameter("msg_erro") != null) { %> 
            <div id="msg_erro"><% out.print(request.getParameter("msg_erro")); %></div>
            <% } %> 
            
            <h1>Noticias</h1>

  
  
		



			<h2>Editar Noticia</h2>	
			
			  <form action="NoticiasEdit" method="post">	 
			  <% Noticia noticia = (Noticia)session.getAttribute("noticia");  %>                      
              <p>
              <span class="titulo_01">
              <strong>Titulo</strong>:<br />
              <input type="text" name="titulo" id="titulo" style="width:280px" value="<% out.print(noticia.getTitulo()); %>"  />
              <br />   
              
              <strong>Categoria:</strong><br />
              </span>
                  <span class="titulo_01">
                  <select name="id_categoria" style="width:280px">
                    <option></option>
  
					<%  	List<Categoria> categorias  = (List<Categoria>)session.getValue("categorias"); %> 

					<% for(int i = 0; i < categorias.size(); i++) {
						Categoria categoria = (Categoria)categorias.get(i); 
					%>  
                    <option value="<%=categoria.getId() %>" <% if(categoria.getId() == noticia.getId_categoria()) { out.print(" selected=\"selected\" "); } %>><%= categoria.getNome() %></option>
                    <%
                    }
                    %>
                  </select>
                  <br />
                  
			    <strong>Corpo da not&iacute;cia:</strong><br />
			      </span>
			    <strong>
			     <textarea name="corpo" id="corpo" style="width:500px"  rows="21"><% out.print(noticia.getCorpo()); %></textarea>
			      </strong>                </p>
			<p><span class="titulo_01"><strong>Tags:</strong> 
			    <input type="text" name="tags" id="tags" style="width:490px" value="<%TagDAO tagDAO = new TagJDBC(); out.print(tagDAO.findByIdNoticia(noticia.getId())); %>" />
				</span><span class="titulo_01"><small>(Separado por v&iacute;rgula: internet, web, google)</small>
				<script>
				$("#tags").autocomplete("/Noticias/TagsAjax", {
					   extraParams: {
					       country: function() { return $("#tags").val(); }
					   }  
					});  
				
				</script>
			  <br />   
              <strong>Data</strong>:<br />
              <input type="text" name="data" id="data" style="width:80px" maxlength="20" value="<% out.print(noticia.data_ddmmyyyy()); %>" onKeyPress="return(formatTyping(this,event,'data'))" onKeyPress="return(formatTyping(this,event,'data'))" >
              <img src="css/calendario.gif" id="trigger_data" onmouseover="return escape('Selecione a data')" style="cursor: pointer;" title="Selecione a data" /> 
               
               <script type="text/javascript">
							  Calendar.setup(
								{
								  inputField  : "data",      
								  ifFormat    : "%d-%m-%Y",   
								  button      : "trigger_data"     
								}
							  );
				</script>
 
              
              <br />   
              <p>
	              <span class="botao_comum" style="float:left">
	              	 <input type="hidden" name="id" id="id" style="width:280px" value="<% out.print(noticia.getId()); %>"  />
	            	  <input type="submit" value="Enviar" />
	              </span>           
              </p>
				
				</form>



		</div> 
        </div> 
      </div> 
      <div id="footer">&nbsp;</div> 
    </div> 
    
    
   <%@ include file="inc_menu.jsp" %>  



    <hr class="hidden"> 
  </div> 
</div> 
</body>
</html>
